
<?php
header('Content-Type:application/json');
$code=array("status"=>false,"msg"=>"","data"=>array());
$mysqli = new mysqli('localhost', 'songsong', '123456', 'sids');
$mysqli->query('set names utf8');
searchRow($mysqli, $code);
$mysqli->close();

function searchRow(mysqli $mysqli, array $code){
    $find = $_GET['find'];
    $query = "select * from student where sno like '%{$find}%'";
    $result = $mysqli->query($query);
    if ($result->num_rows>0){
        $code['data'] = $result->fetch_all(MYSQLI_BOTH);
        $code['status'] = true;
        $code['msg'] = "search success";
    }else {
        $code['status'] = true;
        $code['msg'] = "not object";
    }
    $ret = json_encode($code);
    echo $ret;
}

?>

